//
//  Util.m
//  AMT media manager
//
//  Created by gift ku on 2/5/09.
//  Copyright 2009 __MyCompanyName__. All rights reserved.
//

#import "Util.h"

@implementation NSCell (AMT)

- (void)copyAttributesFromCell:(NSCell*)cell
{
    // cell attributes
    [self setType:[cell type]];
    [self setEnabled:[cell isEnabled]];
    [self setBezeled:[cell isBezeled]];
    [self setBordered:[cell isBordered]];
	
    // state
    [self setState:[cell state]];
	
    // textural attributes
    [self setEditable:[cell isEditable]];
    [self setSelectable:[cell isSelectable]];
    [self setScrollable:[cell isScrollable]];
    [self setAlignment:[cell alignment]];
    [self setFont:[cell font]];
    [self setLineBreakMode:[cell lineBreakMode]];
    [self setWraps:[cell wraps]];
    [self setBaseWritingDirection:[cell baseWritingDirection]];
    [self setAttributedStringValue:[cell attributedStringValue]];
    [self setAllowsEditingTextAttributes:[cell allowsEditingTextAttributes]];
    [self setImportsGraphics:[cell importsGraphics]];
    [self setTitle:[cell title]];
	
    // target/action
    [self setTarget:[cell target]];
    [self setAction:[cell action]];
    [self setContinuous:[cell isContinuous]];
	
    // image/tag
    [self setImage:[cell image]];
    [self setTag:[cell tag]];
	
    // drawing/highlighting
    [self setControlSize:[cell controlSize]];
    [self setControlTint:[cell controlTint]];
    [self setFocusRingType:[cell focusRingType]];
    [self setHighlighted:[cell isHighlighted]];
}



@end

@implementation NSControl (AMT)

- (void)replaceCell:(Class)cellClass
{
    if ([[self cell] class] != cellClass) {
        NSCell* newCell = [[[cellClass alloc] init] autorelease];
        [newCell copyAttributesFromCell:[self cell]];
        [self setCell:newCell];
    }
}

@end
